﻿using FluentAssertions;
using NUnit.Framework;

namespace JsValidator.Tests
{
    [TestFixture]
    public class ConfigTests
    {
        [Test]
        public void Config_1()
        {
            var json = @"{
                          ""outputfile"": ""zxc"",
                          ""CompilationLevel"": ""ADVANCED_OPTIMIZATIONS"",
                          ""WarningLevel"": ""VERBOSE"",
                          ""inputs"": [
                            ""1.js"",
                            ""2.js""
                          ],
                          ""externs"": [
                            ""4.js"",
                            ""5.js""
                          ]
                        }";

            var result = Config.Deserialize(json);

            result.OutputFile.Should().Be("zxc");
            result.CompilationLevel.Should().Be("ADVANCED_OPTIMIZATIONS");
            result.WarningLevel.Should().Be("VERBOSE");
            result.Inputs.Should().BeEquivalentTo(new[] { "1.js", "2.js" });
            result.Externs.Should().BeEquivalentTo(new[] { "4.js", "5.js" });
            result.Ccargs.Should().Be("");
        }

        [Test]
        public void Config_2()
        {
            var json = @"{
                          ""inputs"": [""1.js""]
                        }";

            var result = Config.Deserialize(json);

            result.Inputs.Should().BeEquivalentTo(new[] { "1.js" });
        }

        [Test]
        public void Config_DefaultValues()
        {
            var json = @"{
                        }";

            var result = Config.Deserialize(json);

            result.OutputFile.Should().NotBeNull();
            result.CompilationLevel.Should().Be("ADVANCED_OPTIMIZATIONS");
            result.WarningLevel.Should().Be("VERBOSE");
            result.Inputs.Should().BeEquivalentTo(new string[] { });
            result.Externs.Should().BeEquivalentTo(new string[] { });
            result.IgnoreAllWarnings.Should().BeFalse();
            result.IgnoreWarnings.Should().BeEquivalentTo(new string[] { });
            result.Ccargs.Should().Be("");
        }
    }
}